using UnityEngine;
using System.Collections;

public class FurBall : MonoBehaviour 
{
    public float speed;
	Vector3 pos;
	
	void Start()
	{
		pos = transform.position;
	}
	
	void Update () 
    {
		pos.x -= speed * Time.deltaTime;
		transform.Rotate(Vector3.forward * speed * Time.deltaTime * 3);

        if(!renderer.isVisible)
        {
            Destroy(gameObject);
        }
		
		transform.position = pos;
	}

    void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag == Tags.PLAYER)
        {
            other.gameObject.GetComponent<PlayerMechanic>().GameOver();
            Destroy(gameObject);
        }
    }
}
